class_name GameplayEffect
## Gameplay Effect
## Version: 0.1.0

##
var effect_asset: GameplayEffectAsset

##
var source: AbilitySystemComponent

##
var target: AbilitySystemComponent


func _init(init_effect_asset: GameplayEffectAsset, init_source: AbilitySystemComponent, init_target: AbilitySystemComponent) -> void:
	effect_asset = init_effect_asset
	source = init_source
	target = init_target


func on_attach() -> void:
	if effect_asset.policy != GameplayEffectAsset.Policy.Instant:
		target.tag_manager.add_tags(effect_asset.granted_tags)
		target.ability_manager.grant_abilities(effect_asset.granted_abilities)

	_on_attach()


func on_detach() -> void:
	_on_detach()

	if effect_asset.policy != GameplayEffectAsset.Policy.Instant:
		target.ability_manager.remove_abilities(effect_asset.granted_abilities)
		target.tag_manager.remove_tags(effect_asset.asset_tags)


#region Need to override
func _on_attach() -> void:
	pass


func _on_detach() -> void:
	pass
#endregion
